<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    /*
    *arr.splice(删除数组元素的索引位置,被删除的元素的个数,"新添加的元素");
    *从指定的索引位置删除指定个数的数组元素 arr.splice(index,number);
    *arr.splice(index,0,"新元素");
    *在指定索引位置添加新的元素
    *前两个参数是必须参数，后面参数可选
    *返回值是被删除元素组成的新数组
    */
    var userList = ["zhangsan","lisi","libo","wangwu"];
    var index = userList.indexOf("libo");
    var result = userList.splice(index,1);
    console.log(result);
    console.log(userList);

    userList.splice(1,0,"liuneng","test");
    console.log(userList);
</script>
</html>